Skip to content

feat: implement fs2 plugin to replace @tauri-apps/plugin-fs#3033

Merged
yujonglee merged 8 commits intomainfrom
devin/1768356871-add-fs2-plugin
Jan 14, 2026
Merged

feat: implement fs2 plugin to replace @tauri-apps/plugin-fs#3033
yujonglee merged 8 commits intomainfrom
devin/1768356871-add-fs2-plugin

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Jan 14, 2026

Summary

Implements the fs2 plugin with full functionality to replace all @tauri-apps/plugin-fs usage in the codebase. The plugin performs path validation in Rust using path2's base directory, eliminating the need for permission globs in capabilities/default.json.

Implemented commands:

  • read_text_file - reads text files with path validation against the app's data directory
  • remove - removes files or directories with path validation

Migration completed:

  • Replaced all @tauri-apps/plugin-fs imports with @hypr/plugin-fs2 across 5 source files
  • Updated 6 test files to mock the new fs2 plugin
  • Removed @tauri-apps/plugin-fs npm dependency from package.json
  • Removed tauri-plugin-fs Rust dependency from Cargo.toml and lib.rs
  • Commands return Result type: { status: "ok" | "error", data?: T, error?: string }

Updates since last revision

  • Removed ping command and permission (was scaffolding from initial PR)
  • Updated build.rs to list read_text_file and remove commands
  • Updated default.toml permissions to allow-read-text-file and allow-remove
  • Regenerated TypeScript bindings
  • Completely removed tauri-plugin-fs from both Rust (Cargo.toml, lib.rs) and npm dependencies
  • Simplified capabilities/default.json by removing all fs:* permission globs (~160 lines removed) - path validation is now handled in Rust

Review & Testing Checklist for Human

  • Path validation logic (plugins/fs2/src/ext.rs:18-52): Verify the canonicalization and path validation correctly prevents access outside the base directory, especially for edge cases like symlinks or .. traversal
  • Error handling migration: Confirm all call sites correctly handle the new Result-based API (check for result.status === "error" patterns)
  • Stale schema artifacts: The plugins/fs2/permissions/schemas/schema.json still contains allow-ping/deny-ping references - verify these are cleaned up or regenerated
  • Run tests: pnpm -r test

Test plan:

  1. Run ONBOARDING=0 pnpm -F desktop tauri dev
  2. Create a new session and verify file persistence works (creates/reads files)
  3. Delete a session and verify file removal works
  4. Verify the app cannot access files outside the data directory

Notes

The path validation ensures all file operations stay within the app's data directory (from path2.base()). This is the foundation for eventually allowing users to select their own base directory.

Link to Devin run: https://app.devin.ai/sessions/2060a7b1d34f4f9985fc93a82ccbe3d9
Requested by: @yujonglee

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@netlify
Copy link

netlify bot commented Jan 14, 2026

Deploy Preview for hyprnote canceled.

Name Link
🔨 Latest commit d35efd6
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/69671a0c62feb80008343823

@netlify
Copy link

netlify bot commented Jan 14, 2026

Deploy Preview for hyprnote-storybook canceled.

Name Link
🔨 Latest commit d35efd6
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote-storybook/deploys/69671a0e88197c000812d38d

@netlify
Copy link

netlify bot commented Jan 14, 2026

Deploy Preview for howto-fix-macos-audio-selection canceled.

Name Link
🔨 Latest commit d35efd6
🔍 Latest deploy log https://app.netlify.com/projects/howto-fix-macos-audio-selection/deploys/69671a0c765e630008284cab

- Add readTextFile and remove commands to fs2 plugin
- Implement path validation in Rust using path2's base directory
- Replace all @tauri-apps/plugin-fs usages with fs2 plugin
- Update test files to mock fs2 instead of @tauri-apps/plugin-fs
- Remove @tauri-apps/plugin-fs dependency from package.json

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@devin-ai-integration devin-ai-integration bot changed the title feat: add fs2 plugin wrapping tauri-plugin-fs feat: implement fs2 plugin to replace @tauri-apps/plugin-fs Jan 14, 2026
devin-ai-integration bot and others added 5 commits January 14, 2026 03:53
…rmissions

- Remove ping command from commands.rs, ext.rs, and lib.rs
- Update build.rs to list read_text_file and remove commands
- Update default.toml to list allow-read-text-file and allow-remove permissions
- Remove ping.toml and add read_text_file.toml and remove.toml permission files
- Regenerate TypeScript bindings

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
… into devin/1768356871-add-fs2-plugin

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
- Remove tauri-plugin-fs from Cargo.toml and lib.rs
- Remove all fs: permissions from capabilities/default.json
- fs2 plugin now handles path validation in Rust, no need for permission globs

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@yujonglee yujonglee merged commit 0b40b3e into main Jan 14, 2026
26 of 27 checks passed
@yujonglee yujonglee deleted the devin/1768356871-add-fs2-plugin branch January 14, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant